# Load Libraries & Census Key

library(groundhog)
groundhog.library("tidyverse", "2024-09-22")
groundhog.library("tidycensus", "2024-09-22")
groundhog.library("sf", "2024-09-22")
groundhog.library("kableExtra", "2024-09-22")
groundhog.library("mapview", "2024-09-22")
groundhog.library("ggspatial", "2024-09-22")
groundhog.library("viridis", "2024-09-22")
groundhog.library("viridisLite", "2024-09-22")
groundhog.library("knitr", "2024-09-22")

options(scipen=999)
options(tigris_class = "sf")

source("https://raw.githubusercontent.com/urbanSpatial/Public-Policy-Analytics-Landing/master/functions.r")

census_api_key("2303009ddac130ce0b80796be79521a5421131c9", overwrite = TRUE)

The past couple of decades has marked the flourishment of Transit Orientated Development (TOD) in the city of Boston, MA 1. The primary aim of this development is to create “vibrant, livable, sustainable communities” 2, fostering compact, walkable cities centered around public transit. While the idea sounds like an ideal solution for creating a more accessible future, benefit will not be equitable. The harsh reality–TOD will struggle to deliver on these promises until Boston addresses the scars left by historically-rooted redlining.

#Getting and formatting Tracts for Boston

#2012, ACS-5 Year
tracts12 <-  
  get_acs(geography = "tract",
          variables = c("B01003_001E","B02001_002E",
                        "B15001_050E","B15001_009E",
                        "B19013_001E", "B25058_001E",
                        "B06012_002E"), 
          year=2012, state="MA",
          county="Suffolk", survey="acs5", geometry=TRUE) %>% 
  st_transform('EPSG:2249')

#Remove tract in the water
tracts12_filtered <- tracts12 %>%
  filter(GEOID != "25025990101")

tracts12_filtered <- 
  tracts12_filtered %>%
  dplyr::select( -NAME, -moe) %>%
  spread(key = variable, value = estimate) %>%
  rename(TotalPop = B01003_001, 
         Whites = B02001_002,
         FemaleBachelors = B15001_050, 
         MaleBachelors = B15001_009,
         MedHHInc = B19013_001, 
         MedRent = B25058_001,
         TotalPoverty = B06012_002)

tracts12_filtered <- 
  tracts12_filtered %>%
  mutate(pctWhite = ifelse(TotalPop > 0, Whites / TotalPop, 0),
         pctBachelors = ifelse(TotalPop > 0, ((FemaleBachelors + MaleBachelors) / TotalPop), 0),
         pctPoverty = ifelse(TotalPop > 0, TotalPoverty / TotalPop, 0),
         year = "2012") %>%
  dplyr::select(-Whites,-FemaleBachelors,-MaleBachelors,-TotalPoverty)

#2022, ACS-5 Year
tracts22 <- 
  get_acs(geography = "tract", 
          variables = c("B01003_001E","B02001_002E",
                        "B15001_050E","B15001_009E",
                        "B19013_001E","B25058_001E",
                        "B06012_002E"), 
          year=2022, 
          state=25, 
          county=25, 
          survey="acs5",
          geometry=TRUE,
          output="wide") %>%
  st_transform('EPSG:2249') %>%
  rename(TotalPop = B01003_001E, 
         Whites = B02001_002E,
         FemaleBachelors = B15001_050E, 
         MaleBachelors = B15001_009E,
         MedHHInc = B19013_001E, 
         MedRent = B25058_001E,
         TotalPoverty = B06012_002E) %>%
  dplyr::select(-NAME, -starts_with("B")) %>%
  mutate(pctWhite = ifelse(TotalPop > 0, Whites / TotalPop,0),
         pctBachelors = ifelse(TotalPop > 0, ((FemaleBachelors + MaleBachelors) / TotalPop),0),
         pctPoverty = ifelse(TotalPop > 0, TotalPoverty / TotalPop, 0),
         year = "2022") %>%
  dplyr::select(-Whites, -FemaleBachelors, -MaleBachelors, -TotalPoverty) 

#Combining both years
allTracts2012_22 <- rbind(tracts12_filtered,tracts22)


#Boston Transit Stops Data Wrangling

MBTA_Transit_Stops <- st_read("https://arcgisserver.digital.mass.gov/arcgisserver/rest/services/AGOL/MBTA_Rapid_Transit/MapServer/1/query?outFields=*&where=1%3D1&f=geojson")

MBTA_Stops <- MBTA_Transit_Stops %>%
      dplyr::select(STATION, LINE, ROUTE) %>% st_transform(st_crs(allTracts2012_22))  

MBTA_Stops_clipped <- st_intersection(MBTA_Stops, allTracts2012_22)


#Buffer Data

MBTA_stopBuffer <- st_buffer(MBTA_Stops_clipped, 2640)

MBTA_stopUnion <- st_union(st_buffer(MBTA_Stops_clipped, 2640))

MBTA_Buffers <- 
  rbind(
     MBTA_stopBuffer %>%
      mutate(Legend = "Buffer") %>%
      dplyr::select(Legend),
     MBTA_stopUnion %>%
      st_sf() %>%
      mutate(Legend = "Unioned Buffer"))

buffer_MBTA <- filter(MBTA_Buffers, Legend=="Unioned Buffer")

clip <- 
  st_intersection(buffer_MBTA, allTracts2012_22) %>%
  dplyr::select(TotalPop) %>%
  mutate(Selection_Type = "Clip")


#Spatial selection

# approach #1: sub-setting a spatial object with a spatial object using the '[' brackets.
selection1 <- 
  allTracts2012_22[buffer_MBTA,] %>%
  dplyr::select(TotalPop) %>%
  mutate(Selection_Type = "Spatial Selection")

# approach #2: using `st_intersects` as a verbose way to do approach #1
selection2 <- allTracts2012_22[st_intersects(allTracts2012_22, buffer_MBTA) %>% lengths > 0, ] %>%
  dplyr::select(TotalPop) %>%
  mutate(Selection_Type = "Spatial Selection")

# approach #3: use `st_join` to do a spatial join and remove the non-intersecting polygons
selection3 <- allTracts2012_22 %>% 
  st_join(buffer_MBTA, join = st_intersects) %>% 
  filter(!is.na(Legend)) %>% 
  dplyr::select(TotalPop) %>%
  mutate(Selection_Type = "Spatial Intersects")

selectCentroids <-
  st_centroid(allTracts2012_22)[buffer_MBTA,] %>%
  st_drop_geometry() %>%
  left_join(., dplyr::select(allTracts2012_22, GEOID), by = "GEOID") %>%
  st_sf() %>%
  dplyr::select(TotalPop) %>%
  mutate(Selection_Type = "Select by Centroids")

intersections <- rbind(clip, selection1, selectCentroids)


#Getting summarizing data

MBTA_allTracts.group <- 
  rbind(
    st_centroid(allTracts2012_22)[buffer_MBTA,] %>%
      st_drop_geometry() %>%
      left_join(allTracts2012_22) %>%
      st_sf() %>%
      mutate(TOD = "TOD"),
    st_centroid(allTracts2012_22)[buffer_MBTA, op = st_disjoint] %>%
      st_drop_geometry() %>%
      left_join(allTracts2012_22) %>%
      st_sf() %>%
      mutate(TOD = "Non-TOD")) %>%
  mutate(MedRent.inf = ifelse(year == "2012", MedRent * 1.28, MedRent)) %>% #Using September 2012 v 2022
  mutate(WhitePCT100 = pctWhite * 100) %>%
  mutate(PovertyPCT100 = pctPoverty * 100) %>%
  mutate(BachelorsPCT100 = pctBachelors * 100) %>%
  mutate(MedHHInc.inf = ifelse(year == "2012", MedHHInc * 1.28, MedHHInc)) #Using September 2012 v 2022

#For table, bar graph, & plots
Boston_Summary <- 
  st_drop_geometry(MBTA_allTracts.group) %>%
  group_by(year, TOD) %>%
  summarize(Rent = mean(MedRent.inf, na.rm = T),
            Population = mean(TotalPop, na.rm = T),
            Percent_White = mean(WhitePCT100, na.rm = T),
            #Percent_Bach = mean(BachelorsPCT100, na.rm = T),
            Percent_Poverty = mean(PovertyPCT100, na.rm = T),
            Income = mean(MedHHInc.inf, na.rm = T))

The Shadows of Redlining

The racially segregating process of redlining dates back to the 1930’s, as a result of housing shortages post the Great Depression. To aid in the access to affordable home mortgages, the Home Owners’ Loan Corporation (HOLC) and the Federal Housing Administration (FHA) were established to help stabilize the unsteady state of the market. The FHA made color-coated neighborhood maps of 239 US cities, denoting which areas were investment risks for federally-backed loans3.

HOLC appraisers sectioned of neighborhoods into four color-coded graded sections: “A, Best (green);” “B, Still desirable (blue);” “C, Definitely declining (yellow);” and “D, Hazardous (red).”3.

These drawn boundaries were radically motivated. Primarily, “A” areas were those with dense white and high-income populations, while those marked “D” denoted areas compromised of racial minorities, lower-socioeconomic and immigrant individuals.3. Residents in D-graded (and even C) neighborhoods were systematically denied granted loans and mortgages for homes, leaving them stranded and deprived of homeownership and investments.


Boston was one of the many cities who fell victim to this practice.
knitr::include_graphics("https://github.com/emmawita/MUSA6310-301_Assignment2/blob/7a0dcf01471e8c21bb2341f891ee4e0106026043/figures/Bostons-Redlining-Map-Source-33.png?raw=true")



Many neighborhoods’ demographic compositions still align with the historical boundaries of redlining. Dorchester, Mattapan, Mission Hill, and Roxbury in lower-central Boston remain predominately black neighborhoods.

knitr::include_graphics("https://github.com/emmawita/MUSA6310-301_Assignment2/blob/7a0dcf01471e8c21bb2341f891ee4e0106026043/figures/boston-race-density.png?raw=true")



And, like in most cities, the legacy these redlined communities (referring to the red-color associated with D-grade) continues to linger, widening the gap between equally opportunities.


A Continued History of Exclusion

The majority of transit routes and stop are concentrated along central and northeastern portion of Boston and intersect many redlined communities. Development in the city, historically, has been centered around transit lines, and contemporarily, the large share of housing and jobs are located within proximity to transit4. Approximately 25 and 37% of housing units and employment (in 2012), respectively, fall within half-mile radius of rapid transit or commuter rail station5. Now, with current TOD, the city has a chance to change the landscape—but without addressing this history, the future could look starkly similar to the past.

 

Establishing Equality With TOD

The current trajectory of TOD is hinting towards displacement and gentrification of these historically marginalized individuals in TOD boundaries and within proximity. Communities that were denied investment for decades are now being pushed out when economic prosperity comes.

Lower-socioeconomic individuals are more likely to utilized public transit as commute to work and in daily use6. Now, they are being forced to move farther from the transit systems they’ve relied on for generations. This hinders their chances of social mobility, which has already been suppressed. TOD is meant to aid individuals who depend on transit, yet benefits are not equitable. If Boston fails to tackle the root causes of these inequities, TOD risks continuing the same cycles of exclusion and inequality.


Boston has the opportunity to rectify past injustices and build a more inclusive future. However, it is imperative that the city recognizes and confronts redlining-induced segregation and take action to protect current vulnerable communities.